﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace ArrayListTest
{
    public class Product
    {
        public string Name { get; set; }
        public decimal Price { get; set; }
        public static ArrayList GetArrayList()
        {
            return new ArrayList() {
                new Product {Name = "WindowsPhone", Price = 10m

                },
                new Product {Name = "Apple", Price = 20m

                },
                new Product {Name = "Android", Price = 5m

                }

            };
        }
        public static List<Product> GetList()
        {
            return new List<Product>()
        {
                new Product {Name = "WindowsPhone", Price = 10m},
                new Product {Name = "Apple", Price = 20m},
                new Product {Name = "Android", Price = 5m} };
        }
        public override string ToString()
        {
            return String.Format("{0}--{1}", Name, Price);
        }
    }

    public class ProductCompareT : IComparer<Product>
    {
        public int Compare(Product x, Product y)
        {
            Product first = x as Product;
            Product second = y as Product;
            if (first != null && second != null)
            {
                return first.Price.CompareTo(second.Price);
            }
            else
            {
                return -1;


            }

        }
    }
}
